//
//  GoodsWebViewController.m
//  MyProject
//
//  Created by dllo on 15/10/31.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "GoodsWebViewController.h"
#import "HandleData.h"
#import "UIImageView+WebCache.h"
#import "HandleData.h"
#import "UIImageView+WebCache.h"
#import "MBProgressHUD.h"
@interface GoodsWebViewController ()<UIWebViewDelegate>
{
    
    MBProgressHUD *hud;
}

@property (nonatomic ,strong) NSString *String;
@property (nonatomic ,strong) UIWebView *webView;
@property (nonatomic ,strong) UIView *myview;
@end

@implementation GoodsWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if ([self.goods.type isEqualToString:@"webview"]) {
        UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
        NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.goods.extend]];
        self.webView = webView;
        webView.delegate = self;
        [webView loadRequest:request];
        [self.view addSubview:webView];
        
    }
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
    hud = [[MBProgressHUD alloc]initWithFrame:self.view.bounds];
    [self.view addSubview:hud];
    [hud show:YES];
    hud.detailsLabelText = @"加载中...";
   
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    hud.hidden = YES;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    
    
    
}


- (void)viewWillAppear:(BOOL)animated
{
    if (![[NSUserDefaults standardUserDefaults]boolForKey:@"isWhite"]) {
        self.myview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 100000)];
        [self.webView.scrollView addSubview:_myview];
        _myview.alpha = 0.6;
        _myview.backgroundColor = [UIColor grayColor];
        _myview.userInteractionEnabled = YES;
    }
    else {
        self.myview.hidden = YES;
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
